<html>

<?php

//LaJessica Dixon 
//Date Started: 3/37/2012
//Date Modified: 4/25/2012
$Fname = $_POST['fname'];
$Lname = $_POST['lname'];
$Minit = $_POST['minit'];
$username = $_POST['username'];
$pword = $_POST['password'];
$Phone = $_POST['pnumber'];
$email = $_POST['email'];

//establish the connection to the database

$dbConn=odbc_connect('EventDB','MyUser','Temp123');

//insert participant information
$sql="INSERT INTO Participants VALUES('$Fname', '$Minit', '$Lname',1,'$username', '$pword', '$Phone', '$email')";
$dbexec = odbc_exec($dbConn,$sql);

//this is the select the username that was input into the database
$sql= "SELECT * FROM Participants";

//execute the query
$dbexec = odbc_exec($dbConn,$sql);


//output the execution
$numFields = odbc_num_fields($dbexec);
odbc_fetch_row($dbexec);
$something = odbc_result($dbexec,1);
echo "<table border='1'>";
echo "<tr><th>Participant ID</th><th>FirstName</th><th>Middle Initial</th><th>Last Name</th><th>Group ID</th><th>Username</th><th>Password</th><th>Phone</th><th>Email</th></tr>";
while($row=odbc_fetch_row($dbexec))
{
    echo "<tr>";
    for($i=1;$i<$numFields+1;$i++)
    {
        $col=array();
        $col[$i] = odbc_result($dbexec,$i);
        echo "<td>".$col[$i]."</td>";
    }
}
echo "</tr>";
//loop through the usernames to check if it is already in the database
// for($i = 1; $i <= $numFields; $i++)
// {
    // if($username == odbc_result($dbexec, $i))
    // {
        // echo 'Username Exist';
        // $dbexec2= odbc_exec($dbConn,$sql);
    // }
    
// }



?>
</html>